package com.buka.controller;

import com.buka.service.UserService;
import com.buka.utils.ResponseJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * 用户端
 */
@Controller
@ResponseBody
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户端注册
     */
    @PostMapping("/regis")
    public ResponseJson regis(String username, String password){
        return userService.regis(username,password);
    }

    /**
     * 用户端登录
     */
    @PostMapping("/login")
    public ResponseJson login(String username, String password, HttpSession httpSession){
        return userService.login(username,password,httpSession);
    }
}